;;;Quick "set to existing layer" dialog.
;;;
;;;
;;;	AUTHOR: HENRY C. FRANCIS
;;;		425 N. ASHE ST.
;;;		SOUTHERN PINES, NC 28387
;;;              
;;;		All rights reserved without prejudice.
;;;
;;;	Copyright:	4-28-96
;;;	Edited:		9-11-97
;;;
;;;requires QLAY.DCL
(defun c:qlay ( / it itn lay_f lay_str)
  (lay_list)
  (setq num (load_dialog "qlay"))
  (new_dialog "qlay" num)
  (mode_tile "layer_list" 2)
  (action_tile "layer_list" "(get_tile \"layer_list\")")
  (action_tile "set_layer" "(set_clayr)(done_dialog 0)")
  (start_list "layer_list")
  (mapcar 'add_list vl_list)
  (end_list)
  (set_tile "layer_list" (itoa cur_ndx))
  (start_dialog)
  (princ)
);defun
(defun lay_list ()
  (progn
    (setq cur_lay (getvar"clayer"))
    (setq it (tblnext "layer" "T"))
    (setq itn (cdr(assoc 2 it)))
    (setq newlist (list itn))
    (while
      (setq it (tblnext "layer"))
      (progn
        (setq itn (cdr(assoc 2 it)))
        (setq newlist (append newlist(list itn)))
      );progn
    );while
    (setq newlist (acad_strlsort newlist))
  );progn
  (foreach n newlist
    (if(not(wcmatch n "*|*"))
      (if vl_list
        (setq vl_list (append vl_list (list n)))
        (setq vl_list (list n))
      )
    )
  )
  (setq cur_ndx (-(length vl_list)(length (member cur_lay vl_list))))
)
(defun w_list ()
  (setq lay_f (open (strcat(getvar"dwgname")".LAY") "w"))
  (foreach n vl_list (write-line n lay_f))
  (close lay_f)
)
(defun set_clayr ()
  (setq lay_ndx (atoi (get_tile "layer_list")))
  (setq sel_layer (nth lay_ndx vl_list))
  (setvar "clayer" sel_layer)
  (cond
    ((>(strlen sel_layer)5)
      (setq mjrg (substr sel_layer 1 1)
            llt (substr sel_layer 2 1)
            prod (substr sel_layer 3 4)
      )
    )
  )
  (cond
    ((>(strlen sel_layer)7)
      (setq modf (substr sel_layer 8))
    )
  )
  (princ)
)